> module CHF.Run where
> import CHF.AbsM.Mark1 as M1
> import CHF.AbsM.IOMark1 as IOM1
> import CHF.AbsM.CMark1 as CM1
> import CHF.Transformation.Core2Machine
> import System.Random
> import System.CPUTime

> -------------------------------------------------------------------------------------------------
> -- | 'runMark1' ruft die Mark 1 auf, uebergibt den Ausdruck und Liste frischer Variablennamen
> -------------------------------------------------------------------------------------------------
> runMark1 :: String -> String
> runMark1 input = M1.exec (toMachineExpr input) ["_internal" ++ show x | x <- [1..]]

> -------------------------------------------------------------------------------------------------
> -- | 'runIOMark1' ruft die IO-Mark 1 auf, uebergibt den Ausdruck + Liste frischer Variablennamem
> -------------------------------------------------------------------------------------------------
> runIOMark1 :: String -> String
> runIOMark1 input = IOM1.exec (toMachineExpr input) ["_IOinternal" ++ show x | x <- [1..]]

> -------------------------------------------------------------------------------------------------
> -- | 'runCMark1' ruft die Concurrent-Mark 1 deterministisch auf
> --   als Ressourcen verwendet sie die Liste (Repeat 1).
> -------------------------------------------------------------------------------------------------
> runCMark1 :: String -> String
> runCMark1 input = CM1.exec (toMachineExpr input) ["_Cinternal" ++ show x | x <- [1..]] (repeat 1)


> -------------------------------------------------------------------------------------------------
> -- | 'runCM1' mit nichtdeterministischem Randomaufruf
> -------------------------------------------------------------------------------------------------
> runCM1 :: String -> IO ()
> runCM1 input = do
>					seed	<- getCPUTime
>					setStdGen (mkStdGen (fromInteger seed))
>					gen		<- getStdGen
>					let 
>						expr 		= toMachineExpr input
>						freshVars	= ["_internal" ++ show x | x <- [1..]]
>						zufall		= map abs (randoms gen) :: [Int]
>						in print (CM1.exec expr freshVars zufall)



> -- ~~~~~~~~~~~~~~~~~~~[random test]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> zufallsListe :: Int -> [Int]
> zufallsListe seed = take 10 (map abs (randoms (mkStdGen seed)))
> -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
